package cn.xiangxu.telecom.login.service;

import java.io.Serializable;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import cn.xiangxu.telecom.login.dao.AdminDao;
import cn.xiangxu.telecom.login.entity.Admin;

@Repository("loginService")
public class LoginSericeImpl implements Serializable, LoginSerice {
	@Resource(name="adminDao")
	private AdminDao ad;
	
	public Admin checkLogin(String adminCode, String password) {
		Admin admin = ad.findByAdminCode(adminCode);
		if(null == admin) {
//			登录失败：用户名错误
			throw new ApplicationException("用户名错误");
		}
		if(!password.equals(admin.getPassword())) {
//			登录失败：密码错误
			throw new ApplicationException("密码错误");
		}
//		登录成功：验证通过
		return admin;
	}

}
